#!/usr/bin/python3

from fathomtools import FathomArgumentParser

from fathomtools.django import DjangoExporter

DESCRIPTION = 'Build django models from database schema.'

def main():
    parser = FathomArgumentParser(description=DESCRIPTION)
    parser.add_argument('-o', '--output', help='print output to a file')
    parser.add_argument('--filter', help='regular expression by which tables '
                                         'will be filtered')
    parser.add_argument('--ignore-through-tables', action='store_true',
                        default=False, help="don't build through tables")
    parser.add_argument('--ignore-foreign-keys', action='store_true',
                        default=False, help="don't build foreign keys")
            
    db, args = parser.parse_args()
    build_through_tables = (not args.ignore_through_tables)
    build_foreign_keys = (not args.ignore_foreign_keys)
    DjangoExporter(db, filter=args.filter, output=args.output,
                   build_through_tables=build_through_tables,
                   build_foreign_keys=build_foreign_keys).run()

if __name__ == "__main__":
    main()
